home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: surfnet.nl!sun4nl!hcsrnd!root
- From: paulw@gti-ia.nl (Paul Wallis)
- Subject: Re: C coding standards
- Message-ID: <DnuLzM.8xr@gti-ia.nl>
- Sender: root@gti-ia.nl (Operator)
- Reply-To: paulw@gti-ia.nl
- Organization: GTI Industrial Automation, Apeldoorn
- References: <313B4548.45AA@oc.com>
- Date: Wed, 6 Mar 1996 13:40:34 GMT
-
- Teresa Reiko wrote:
- > In this book and others, notably 'Code Complete', these programming
- > guides published by Microsoft Press, it is evident why Microsoft put
- > so many bugs in Windows 95. Here are the three worst Microsoft
- > coding rules, in my opinion at least:
- >
- > Every line of code must contain a comment.
- > Any number greater than 2 must be a named constant.
- > No procedure may be longer than 25 lines.
- >
- > If you follow these rules, you can be sure to write buggy, inefficient
- > code that is difficult to revise and will generally look 'dirty'.
- > Of course, if this is your intent, that's OK, but...
- >
- I am sorry, but I feel compelled to answer this, even though the debate does NOT
- belong in this newsgroup. I believe IMHO that you have maligned an excellent book.
- I have read this book cover to cover and agreed with 90% of what the author says.
- And before you go on to 'slate' me, I think you aught to re-read the book and actually
- look at what is said.
-
- The Code Complete definately does not say that every line should have a comment.
- In fact it says that you should be able to read what the code is meant to do without
- resorting to comments every line. The author tries to put across the idea that
- comments bear a purpose and are not a cross to be born.
-
- It suggests that a _guideline_ to function length would be one page long; going on
- to say that a page could be 25 lines 60 lines or even 120 lines depending upon wha
- you use for display.
-
- As for ridiculing the fact that numbers greater than 2 should be a named constant.
- I really can't see your argument there. It has, as far as I'm aware, always been
- common practice in the 'C' programming community to write:
-
- #define NAME_LIMIT 39
- char name[NAME_LIMIT];
-
- as opposed to:
-
- char name[39];
-
- And IMHO the former is far easier to read an when you wish to upgrade or modify the
- length of a name you only have to change the #define as opposed to searching through
- all of your code for the number 39 and doing a replace...
-
- Regards,
- Paul
- ---
-
- = =
- === === GTI Contact me at
- ============ Industrial paulw@gti-ia.nl
- = = Automation b.v. Of course my opinions
- === === are my own?! Who else
- ============ The Netherlands is that mad?!
-
-
-